package com.zzptc.shop.dao;

import com.zzptc.shop.db.IDB;
import com.zzptc.shop.db.MysqlDB;
import com.zzptc.shop.Factory.DaoFactoryImp;
import com.zzptc.shop.vo.Good;
import com.zzptc.shop.vo.VO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class ProductDao implements IDAO{


    @Override
    public boolean insert(VO vo) throws SQLException {
        return false;
    }

    @Override
    public List getAll() throws SQLException {

        IDB db=new MysqlDB();
        Connection conn=db.getConnection();
        PreparedStatement ps=conn.prepareStatement("select * from t_easybuy_product_category");
        ResultSet rs=ps.executeQuery();
        while(rs.next()){
            Good dog=new Good();
            dog.setEpc_id(rs.getInt("1"));
            dog.setEpc_name(rs.getString("2"));
            dog.setEpc_parent_id(rs.getInt("3"));

        }

        return null;
    }

    @Override
    public boolean deleteByID(VO vo) throws SQLException {
        return false;
    }

    @Override
    public boolean update(VO vo) throws SQLException {
        return false;
    }

    @Override
    public VO getByID(VO vo) throws SQLException {
        return null;
    }

    public static void main(String[] args) throws Exception {
        try {
            ProductDao dao = (ProductDao) DaoFactoryImp.getInstance().createDAO("productdao");
            dao.getAll();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
